package com.retain.system.vo;

import com.retain.system.dto.UserDTO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @author: LiuWei
 * @date: Create in 16:20 2018/10/15
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserVO {
    private Long id;

    private String account;

    private String passWord;

    private List<RoleVO> roles;

    private List<ResourceVO> resources;

    public static final UserVO buildUserVO(final UserDTO userDTO, final List<RoleVO> roles,
                                           final List<ResourceVO> resources) {
        if(userDTO !=null){
            UserVO  userVO = new UserVO();
            userVO.setId(userDTO.getId());
            userVO.setAccount(userDTO.getAccount());
            userVO.setRoles(roles);
            userVO.setResources(resources);
            userVO.setPassWord(userDTO.getPassword());
            return userVO;
        }
        return null;
    }

}
